<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var root = {
            name: "A",
            expend: 26,
            left: {
                name: "B",
                need: 3,
                expend: 53,
                left: {
                    name: "E",
                    need: 1
                },
                right: {
                    name: "F",
                    need: 5
                }
            },
            middle: {
                name: "C",
                need: 1
            },
            right: {
                name: "D",
                need: 4,
                expend: 58,
                right: {
                    name: "G",
                    need: 9
                }
            }
        }
        var n = 10000;
        var equipmentE = 10;
        var equipmentF = 20;
        var equipmentC = 20;
        var equipmentG = 40;
        var amount = 0;
        function calculate(root) {
            if (root == null) return;
            
        }
        calculate(root);
        
    </script>
</body>

</html>